package com.emellend.api11.media;

import java.io.File;

import com.emellend.api11.R;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class VideoViewDemo extends Activity {
	private VideoView mVideoView;
	private String path = "";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.videoview);
		mVideoView = (VideoView) findViewById(R.id.surface_view);
		initPah();
		if (path == "") {
            Toast.makeText(this, "视频文件不存在",Toast.LENGTH_LONG).show();

        } else {
            mVideoView.setVideoPath(path);
            mVideoView.setMediaController(new MediaController(this));
            mVideoView.requestFocus();
        }
	}

	private void initPah() {
		if (Environment.getExternalStorageState()!=Environment.MEDIA_UNMOUNTED) {
			File file=new File(Environment.getExternalStorageDirectory(), "yanni 2006_Until the Last Moment.3gp");
			if (file.exists()&&file.isFile()) {
				path=file.getAbsolutePath();
			}
		}
	}
}
